package com.zzyl.mapper;

import com.github.pagehelper.Page;
import com.zzyl.entity.NursingPlan;
import com.zzyl.vo.NursingPlanVo;
import com.zzyl.vo.NursingProjectPlanVo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;

import java.util.List;

/**
 * @Description NursingPlanMapper
 * @Author mzx
 * @Date 2024-07-08
 */
@Mapper
public interface NursingPlanMapper {
    /**
     * 护理计划分页查询
     *
     * @param name
     * @param status
     * @return
     */
    Page<NursingPlanVo> getBypage(String name, Integer status);

    /**
     * 新增护理计划
     *
     * @param nursingProjectPlanVoList
     */
    void add(List<NursingProjectPlanVo> nursingProjectPlanVoList);

    /**
     * 根据id查询护理计划
     *
     * @param id
     * @return
     */
    NursingPlanVo findById(Integer id);


    /**
     * 修改护理计划
     *
     * @param nursingProjectPlanVoList
     */
    void updateById(NursingPlan nursingPlan);

    /**
     * 修改护理计划状态
     * @param id
     * @param status
     */
    void updateStatus(Integer id, Integer status);

    /**
     *  查询所有护理计划
     * @return
     */
    List <NursingPlanVo>  findAll();

    //新增护理计划到计划表同时返回id
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into nursing_plan(plan_name,sort_no,remark,create_by,update_by,create_time,update_time)\n" +
            "        values\n" +
            "        (#{planName},#{sortNo},#{remark},#{createBy},#{updateBy},#{createTime},#{updateTime})")
    void addPlan(NursingPlan nursingPlan);

    @Delete("delete from nursing_plan where id=#{id}")
    void deleteId(Integer id);
}
